import { defineStore } from 'pinia';
import { GoodsCategoryVO } from '@/api/mall/goodsCategory/types';
import { listGoodsCategory } from '@/api/mall/goodsCategory';

export const useCategoryStore = defineStore(
  'category',
  () => {
    // 导航列表的数据管理
    // state 导航列表数据
    const goodsCategoryList = ref<GoodsCategoryVO[]>([]);
    /*全部分类*/
    const getCategory = async () => {
      const res = await listGoodsCategory();
      // localStorage.setItem('category',res.data)
      console.log(res)
      goodsCategoryList.value = res.data;

    };

    return {
      goodsCategoryList,
      getCategory
    };
  },
  {
    persist: true //同步到本地
  }
);
export default useCategoryStore;
